package com.heima.comment.controller;

import com.heima.comment.service.AppCommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentSaveDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class AppCommentController {

    @Autowired
    private AppCommentService appCommentService;

    /**
     * 发布评论
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentSaveDto dto) {
        return appCommentService.save(dto);
    }

    /**
     * ###  查询评论列表
     * **接口地址**:`/api/v1/comment/load`
     * **请求方式**:`POST`
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDto dto){
        return  appCommentService.load(dto);
    }

    /**
     * ###  点赞
     * **接口地址**:`/api/v1/comment/like`
     * **请求方式**:`POST`
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return  appCommentService.like(dto);
    }
}
